hvm vmx: VMX MSR bitmap format and size is VMX-specific, so move its
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 2 Apr 2007 15:59:00 +0000 (16:59 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 2 Apr 2007 15:59:00 +0000 (16:59 +0100)
allocation and initialisation into VMX-specific code.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/support.h
xen/include/asm-x86/hvm/vmx/vmcs.h

index 60b415ea15b5ea7beef0f1b75e210fc41c34410c..552caca82228bc4a69b4328b07716348bd71c184 100644 (file)
@@ -59,9 +59,6 @@ struct hvm_function_table hvm_funcs __read_mostly;
 /* I/O permission bitmap is globally shared by all HVM guests. */
 char __attribute__ ((__section__ (".bss.page_aligned")))
     hvm_io_bitmap[3*PAGE_SIZE];
-/* MSR permission bitmap is globally shared by all HVM guests. */
-char __attribute__ ((__section__ (".bss.page_aligned")))
-    hvm_msr_bitmap[PAGE_SIZE];
 
 void hvm_enable(struct hvm_function_table *fns)
 {
@@ -75,9 +72,6 @@ void hvm_enable(struct hvm_function_table *fns)
     memset(hvm_io_bitmap, ~0, sizeof(hvm_io_bitmap));
     clear_bit(0x80, hvm_io_bitmap);
 
-    /* All MSR accesses are intercepted by default. */
-    memset(hvm_msr_bitmap, ~0, sizeof(hvm_msr_bitmap));
-
     hvm_funcs   = *fns;
     hvm_enabled = 1;
 }
index beed602f9b40c80c2ea0d72b10d023f64dfc77fa..977a98ce3c6773ec3724307db3543546982875bf 100644 (file)
@@ -289,7 +289,7 @@ static void construct_vmcs(struct vcpu *v)
     v->arch.hvm_vcpu.u.vmx.exec_control = vmx_cpu_based_exec_control;
 
     if ( cpu_has_vmx_msr_bitmap )
-        __vmwrite(MSR_BITMAP, virt_to_maddr(hvm_msr_bitmap));
+        __vmwrite(MSR_BITMAP, virt_to_maddr(vmx_msr_bitmap));
 
     /* I/O access bitmap. */
     __vmwrite(IO_BITMAP_A, virt_to_maddr(hvm_io_bitmap));
index 368733c1a665aa8c9e3112ba10a7f7380efa34f8..e1fe8290e5ea630228e11a1c0c38dce9577fafa7 100644 (file)
@@ -51,6 +51,8 @@
 #include <public/hvm/save.h>
 #include <asm/hvm/trace.h>
 
+char *vmx_msr_bitmap;
+
 static void vmx_ctxt_switch_from(struct vcpu *v);
 static void vmx_ctxt_switch_to(struct vcpu *v);
 
@@ -1005,14 +1007,14 @@ static void disable_intercept_for_msr(u32 msr)
      */
     if ( msr <= 0x1fff )
     {
-        __clear_bit(msr, hvm_msr_bitmap + 0x000); /* read-low */
-        __clear_bit(msr, hvm_msr_bitmap + 0x800); /* write-low */
+        __clear_bit(msr, vmx_msr_bitmap + 0x000); /* read-low */
+        __clear_bit(msr, vmx_msr_bitmap + 0x800); /* write-low */
     }
     else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) )
     {
         msr &= 0x1fff;
-        __clear_bit(msr, hvm_msr_bitmap + 0x400); /* read-high */
-        __clear_bit(msr, hvm_msr_bitmap + 0xc00); /* write-high */
+        __clear_bit(msr, vmx_msr_bitmap + 0x400); /* read-high */
+        __clear_bit(msr, vmx_msr_bitmap + 0xc00); /* write-high */
     }
 }
 
@@ -1105,6 +1107,9 @@ int start_vmx(void)
     if ( cpu_has_vmx_msr_bitmap )
     {
         printk("VMX: MSR intercept bitmap enabled\n");
+        vmx_msr_bitmap = alloc_xenheap_page();
+        BUG_ON(vmx_msr_bitmap == NULL);
+        memset(vmx_msr_bitmap, ~0, PAGE_SIZE);
         disable_intercept_for_msr(MSR_FS_BASE);
         disable_intercept_for_msr(MSR_GS_BASE);
     }
index fea8611bf8ab838263d4c629e66affa5ee2f23a0..3d7b3a43bbd26b1fcd6d0fb86d53aaf7691215fb 100644 (file)
@@ -215,7 +215,6 @@ int hvm_load(struct domain *d, hvm_domain_context_t *h);
 /* End of save/restore */
 
 extern char hvm_io_bitmap[];
-extern char hvm_msr_bitmap[];
 extern int hvm_enabled;
 
 void hvm_enable(struct hvm_function_table *);
index 23a0b71be078b05dd245383d39875f0da278cc1d..1391941ab57f8f9ddd6a7a3c0a4ecd89b655f036 100644 (file)
@@ -121,6 +121,7 @@ extern u32 vmx_vmentry_control;
 
 #define cpu_has_vmx_msr_bitmap \
     (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP)
+extern char *vmx_msr_bitmap;
 
 /* VMCS Encordings */
 enum vmcs_field {